﻿using Services.DataSource.Schedule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class ScheduleServer:ISchedule
    {
        public List<Schedules> GetMyUnfinishSchedules(string uid)
        {
            if (string.IsNullOrEmpty(uid))
            {
                return null;
            }
            DB_Schedules db = new DB_Schedules();
            return db.GetMySchedulesByStatus(uid, (int)Status.Unfinish);
        }

        public List<Schedules> GetMyPeddingSchedules(string uid)
        {
            if (string.IsNullOrEmpty(uid))
            {
                return null;
            }
            DB_Schedules db = new DB_Schedules();
            return db.GetMySchedulesByStatus(uid, (int)Status.Pedding);
        }

        public List<Schedules> GetMyFinishSchedules(string uid)
        {
            if (string.IsNullOrEmpty(uid))
            {
                return null;
            }
            DB_Schedules db = new DB_Schedules();
            return db.GetMySchedulesByStatus(uid, (int)Status.Finish);
        }

        public List<Schedules> GetMyApproveSchedules(string uid)
        {
            if (string.IsNullOrEmpty(uid))
            {
                return null;
            }
            DB_Schedules db = new DB_Schedules();
            return db.GetMyApproveSchedules(uid, (int)Status.Pedding);
        }

        public bool InsertSchedules(Schedules schedule)
        {
            if (schedule == null)
            {
                return false;
            }
            DB_Schedules db = new DB_Schedules();
            return db.Insert(schedule);
        }

        public bool UpdateSchedules(Schedules schedule)
        {
            if (schedule == null)
            {
                return false;
            }
            DB_Schedules db = new DB_Schedules();
            return db.Update(schedule);
        }

        public bool DeleteSchedule(int id)
        {
            if (id > 0)
            {
                DB_Schedules db = new DB_Schedules();
                return db.Delete(id);
            }
            return false;
        }

        public Schedules GetScheduleById(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                DB_Schedules db = new DB_Schedules();
                return db.GetScheduleById(id);
            }
            return null;
        }
    }
}
